package springinaction.events;

import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;


public class CustomEventDispatcher implements ApplicationEventPublisherAware {
	
	private ApplicationEventPublisher dispatcher;

	@Override
	public void setApplicationEventPublisher(ApplicationEventPublisher dispatcher) {
		this.dispatcher = dispatcher;
	}
	
	public void dispatch(){
		Course course = new Course(); //as event param
		course.name = "Informatics";		
		CustomEvent event = new CustomEvent(this, course);
		
		dispatcher.publishEvent(event);
	}
}
